package com.wuyan.locationdog.adapter

import android.graphics.Color
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.MsgBeanContent
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.loadImageCircleCar
import com.arcsoft.commonbase.ext.radius
import com.arcsoft.commonbase.ext.visible
import com.arcsoft.commonbase.ext.visibleOrGone
import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import leifu.shapelibrary.ShapeView


class MsgDetailListAdapter(@LayoutRes layoutResId: Int, data: MutableList<MsgBeanContent>?) :
    BaseQuickAdapter<MsgBeanContent, BaseViewHolder>(layoutResId, data) {


    var isDelete = false

    override fun convert(holder: BaseViewHolder, item: MsgBeanContent) {
        //noticeType 消息通知类型1报警 2待接受共享 3已接受共享 4共享被接受 5已取消
        holder.apply {
            getView<TextView>(R.id.createTime).text = item.createTime


            getView<ShapeView>(R.id.btnAccept).gone()
            getView<TextView>(R.id.createTime).visible()
            val shareStatus = getView<TextView>(R.id.shareStatus)
            ///用户消息类型1报警 2系统通知
            if (item.billType == 1) {

            } else {
                getView<TextView>(R.id.alarmAddress).text = item.noticeContent

            }
            //时分秒
            getView<TextView>(R.id.createTime).text = item.createTime
//                item.createTime.subSequence("yyyy-MM-dd ".length, "yyyy-MM-dd HH:mm:ss".length)
            ///用户消息类型1报警 2共享通知 3团队邀请通知 4指令通知
            when (item.billType) {
                1 -> {
                    getView<TextView>(R.id.title).text = item.deviceName
                    getView<ImageView>(R.id.icon).loadImageCircleCar(item.dogImg)
                }

                2 -> {
                    getView<TextView>(R.id.title).text = "共享"
                    getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_share)
                }

                3 -> {
                    getView<TextView>(R.id.title).text = "团队"
                    getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_team)
                }

                4 -> {
                    getView<TextView>(R.id.title).text = "指令"
                    getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_cmd)
                }
            }

            //消息通知类型1报警 2待接受共享 3已接受共享 4共享被接受 5已取消
            when (item.noticeType) {
                1 -> {
                    getView<TextView>(R.id.alarmTypeDesc).text = item.alarmTypeDesc
                }

                2 -> {
                    getView<ShapeView>(R.id.btnAccept).visible()
                    shareStatus.setText("待接受共享")

                }

                3 -> {
                    shareStatus.setText("已接受")

                }

                4 -> {
                    shareStatus.setText("共享被接受")

                }

                5 -> {
                    shareStatus.setText("已取消共享")
                }

                6 -> {
                    shareStatus.setText("等待对方接受")
                }

                7 -> {
                    getView<ShapeView>(R.id.btnAccept).visible()

                    shareStatus.setText("团队邀请")
                }

                8 -> {
                    shareStatus.setText("邀请成功")
                }

                9 -> {
                    shareStatus.setText("接受邀请")
                }

            }


        }
    }
}


